<template>
  <div class="title-btns block">
    <el-button type="primary" @click="addClickEvent" v-if="hasAuth(auth, 'plus')">
      {{$t('ship.button.plus')}}
    </el-button>
  </div>

  <el-table
      stripe
      class="daf-table"
      :data="listData"
      style="width: 100%">
    <el-table-column
        prop="id"
        label="机构ID"
        >
    </el-table-column>
    <el-table-column
        prop="name"
        label="机构名称"
        >
    </el-table-column>
    <el-table-column
        prop="phone"
        label="联系手机"
        >
    </el-table-column>
    <el-table-column
        label="启用状态">
      <template #default="scope">
        <span>{{enableStatuss[scope.row.enable]}}</span>
      </template>
    </el-table-column>
    <el-table-column
        label="审核状态">
      <template #default="scope">
        <el-tag v-if="scope.row.check==2" type="success">{{checkStatuss[scope.row.check]}}</el-tag>
        <el-tag v-if="scope.row.check==1" type="warning">{{checkStatuss[scope.row.check]}}</el-tag>
        <el-tag v-if="scope.row.check==0" type="danger">{{checkStatuss[scope.row.check]}}</el-tag>
      </template>
    </el-table-column>
     
    <el-table-column
        prop="remark"
        label="审核备注">
    </el-table-column>
    <el-table-column
        prop="createTime"
        label="创建时间">
    </el-table-column>
    <el-table-column
        prop="updateTime"
        label="修改时间">
    </el-table-column>
    <el-table-column
      label="Operation">
      <template #default="scope">
        <span v-if="hasAuth(auth, 'edit')" class="btn-primary" @click="editClickEvent(scope.row)">{{$t('ship.button.edit')}}</span>&nbsp;
        <span v-if="hasAuth(auth, 'remove')" class="btn-primary" @click="removeClickEvent(scope.row.id)">{{$t('ship.button.remove')}}</span>
      </template>
    </el-table-column>
  </el-table>

  <el-dialog
      :width="500"
      :title="dialogTitle"
       destroy-on-close
       v-model="dialogFormVisible"
       @close="orgForm.resetFields()">
    <el-form :model="formParam" :rules="rules" ref="orgForm">
      <el-form-item label="机构名称" label-width="80px" prop="name">
        <el-input v-model="formParam.name" autocomplete="off" clearable></el-input>
      </el-form-item>
      <el-form-item label="联系手机" label-width="80px" prop="phone">
        <el-input v-model="formParam.phone" autocomplete="off" maxlength="11" clearable></el-input>
      </el-form-item>
      <el-form-item label="启用状态" label-width="80px" prop="enable">
        <el-select v-model="formParam.enable" placeholder="请选择启用状态">
          <el-option
            :key="index"
            :label="item"
            :value="index"
            v-for="(item, index) in Object.values(enableStatuss)"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" label-width="80px" prop="check">
        <el-select v-model="formParam.check" placeholder="请选择审核状态">
          <el-option
            :key="index"
            :label="item"
            :value="index"
            v-for="(item, index) in Object.values(checkStatuss)"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="审核备注" label-width="80px" prop="remark">
        <el-input v-model="formParam.remark" autocomplete="off" clearable></el-input>
      </el-form-item> -->
      <el-form-item label="营业执照" label-width="80px" prop="img">
        <div class="flex-left">
          <img v-if="formParam.img" :src="formParam.img" width="100"/>
          <i class="el-icon-upload" onclick="this.nextSibling.click()"></i>
          <input id="upload-file" type="file" v-show="false" @change="showImg">
        </div>
      </el-form-item>
    </el-form>
    <template #footer>
    <span class="dialog-footer">
      <el-button @click="dialogFormVisible=false">Cancel</el-button>
      <el-button @click="resetForm" type="warning">Reset</el-button>
      <el-button type="primary" @click="submitForm">Save</el-button>
    </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" src="./org.ts"></script>

<style scoped lang="scss" src="./index.scss"></style>
